package com.example.khandasawanat;

import java.util.List;
import java.util.Locale;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.khandasawanat.Restaurant;
import com.example.khandasawanat.SubMenuFragment;

public class FragmentAdapter extends FragmentPagerAdapter {
	private List<Restaurant> restaurantList;
	public List<Restaurant> getRestaurantList() {
		return restaurantList;
	}

	public void setRestaurantList(List<Restaurant> restaurantList) {
		this.restaurantList = restaurantList;
	}

	public FragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int position) {
		// getItem is called to instantiate the fragment for the given page.
		// Return a DummySectionFragment (defined as a static inner class
		// below) with the page number as its lone argument.
		Fragment fragment = new SubMenuFragment();
		Bundle args = new Bundle();
		args.putInt(SubMenuFragment.ARG_SECTION_NUMBER, position + 1);
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public int getCount() {
		// Show 3 total pages.
		return restaurantList.get(0).restaurantMenu.getSubMenuCount();
	}

	@Override
	public CharSequence getPageTitle(int position) {
		Locale l = Locale.getDefault();
		return restaurantList.get(0).restaurantMenu.getSubMenuTitle(position);
		// return null;
	}
}